package core.net.protocol;

import core.buffer.Buffer;

public class MoveP extends FrameP {

    public static final byte TYPE = 1;
    public int x;
    public int y;

    @Override
    public void deserialize(Buffer data) {
        super.deserialize(data);
        x = data.readInt();
        y = data.readInt();

    }

    @Override
    public Buffer serialize(Buffer emptyBuffer) {
        super.serialize(emptyBuffer);
        emptyBuffer.writeInt(x);
        emptyBuffer.writeInt(y);
        return emptyBuffer;
    }

    @Override
    public byte protocolType() {
        return TYPE;
    }

    @Override
    public int size() {
        return 4 + 4 + super.size();
    }

    @Override
    public String toString() {
        return "MoveP " + super.toString() + " x:" + x + " y:" + y;
    }
}
